from mainapp.models import TUser, Project


def page_(uid, pid):
    user = TUser.objects.get(pk=uid)
    news = Project.objects.filter(user=user)
    l = []
    data = {}
    for n in news:
        l.append(n.id)
    print(l, type(pid), pid)
    m = l.index(int(pid))
    if m > 0:
        left = m - 1
        data['left'] = (Project.objects.get(pk=l[left]).title, Project.objects.get(pk=l[left]).id)
    else:
        data['left'] = ('没有了', 0)
    if m < len(l) - 1:
        right = m + 1
        data['right'] = (Project.objects.get(pk=l[right]).title, Project.objects.get(pk=l[right]).id)
    else:
        data['right'] = ('没有了', 0)



